﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using SDT.Model;
using System.Linq.Dynamic;
using SDT.Site.ViewModels;
using SDT.Site.Properties;
namespace SDT.Site.Controllers
{
    public class UsefulController : Controller
    {
        //
        // GET: /Useful/
        SDTDataContext db = new SDTDataContext();
        public ActionResult Index()
        {
            return View();
        }
        [ChildActionOnly]
        public ActionResult Lasted(int number)
        {
            UsefulViewModels u = new UsefulViewModels();
            u.Usefuls = db.Usefuls.OrderBy(string.Format("{0} {1}", "ID", "asc")).Take(number).ToList();
            u.ImageUrl = Settings.Default.SiteRootUrl + Settings.Default.UsefulImagePreviewUrlPrefix;
            u.ImagePath = Settings.Default.SiteRootPath + Settings.Default.UsefulImageRootPath;    
            return View(u);
        }
        [ChildActionOnly]
        public ActionResult LastedSmall(int number)
        {
            UsefulViewModels u = new UsefulViewModels();
            u.Usefuls = db.Usefuls.OrderBy(string.Format("{0} {1}", "ID", "asc")).Take(number).ToList();
            u.ImageUrl = Settings.Default.SiteRootUrl + Settings.Default.UsefulImagePreviewUrlPrefix;
            u.ImagePath = Settings.Default.SiteRootPath + Settings.Default.UsefulImageRootPath;
            return View(u);
        }
    }
}
